import {ProColumnType} from "@ant-design/pro-components";
import {Link} from "umi";
import { Tag} from "antd";

export type DataType = {
  id:string;
  age: number;
  address: string;
  interfaceName: string;
  time: number;
  key: number;
  description: string;
  url:string;
  avatarUrl:string;
  calledNum:number;
  requestExample:string;
  requestHeader:string;
  requestParams:string;
  status:1;
  requestMethod:string;
  createTime:string
};
export const interfaceColumns: ProColumnType<DataType>[] = [
  {
    dataIndex: 'id',
    valueType: 'index',
    hideInTable: true,
    key: 'id',
  },
  {
    title: '接口名称',
    dataIndex: 'interfaceName',
    copyable: true,
    valueType: 'text',
    render: (_, record) => (
      <Link key={record.id} to={`/interface/detail/${record.id}`}>
        {record.interfaceName}
      </Link>
    ),
    ellipsis: true,
    key: 'interfaceName',
  },
  {
    title: '接口地址',
    dataIndex: 'url',
    valueType: 'text',
    ellipsis: true,
    copyable: true,
    key: 'url',
  },
  {
    title: '返回格式',
    key: "JSON",
    dataIndex: 'JSON',
    valueType: "text",
    hideInSearch:true
  },
  {
    title: '接口图像',
    dataIndex: 'avatarUrl',
    valueType: 'image',
    width: 100,
    key: 'avatarUrl',
    hideInSearch:true
  },
  {
    title: '总调用次数',
    dataIndex: 'calledNum',
    valueType: 'text',
    search: false,
    key: "calledNum",
  },
  {
    title: '接口描述',
    dataIndex: 'description',
    valueType: 'textarea',
    copyable: true,
    search: false,
    ellipsis: true,
    key: 'description',
  },
  {
    title: '请求示例',
    dataIndex: 'requestExample',
    key: 'requestExample',
    valueType: 'text',
    width: 120,
    search: false,
    copyable: true,
    ellipsis: true,
  },
  {
    title: '请求头',
    dataIndex: 'requestHeader',
    valueType: 'text',
    search: false,
    width: 120,
    ellipsis: true,
    copyable: true,
    key: 'requestHeader',
  },
  {
    title: '请求参数',
    dataIndex: 'requestParams',
    valueType: 'text',
    search: false,
    width: 120,
    ellipsis: true,
    copyable: true,
    key: 'requestParams',
  },
  {
    title: '状态',
    filters: true,
    onFilter: true,
    width: 100,
    dataIndex: 'status',
    key: 'status',
    valueEnum: {
      0: {
        text: '已发布',
        status: 'Default',
      },
      1: {
        text: '已下线',
        status: 'Error',
      },

    },
  },
  {
    title: '请求类型',
    dataIndex: 'requestMethod',
    filters: true,
    width: 100,
    onFilter: true,
    valueType: 'text',
    key: 'requestMethod',
    render: (_, record) => (
      <Tag color="processing">{record.requestMethod}</Tag>
    ),
    valueEnum: {
      GET: {
        text: 'GET',
      },
      POST: {
        text: 'POST',
      },
      PUT: {
        text: 'PUT',
      },
      DELETE: {
        text: 'DELETE',
      },
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    valueType: 'dateTime',
    key: 'createTime',
    search: false,
  },

];


